package com.designpatterns.adapterpattern.mediaplayer.impl;

import com.designpatterns.adapterpattern.advancedmediaplayer.AdvancedMediaPlayer;
import com.designpatterns.adapterpattern.advancedmediaplayer.impl.Mp4Player;
import com.designpatterns.adapterpattern.advancedmediaplayer.impl.VlcPlayer;
import com.designpatterns.adapterpattern.mediaplayer.MediaPlayer;

public class MediaAdapter implements MediaPlayer
{
	AdvancedMediaPlayer advancedMusicPlayer;

	//有参构造方法
	public MediaAdapter(String audioType)
	{
		if (audioType.equalsIgnoreCase("vlc"))
		{
			advancedMusicPlayer = new VlcPlayer();
		} else if (audioType.equalsIgnoreCase("mp4"))
		{
			advancedMusicPlayer = new Mp4Player();
		}
	}

	@Override
	public void play(String audioType, String fileName)
	{
		if (audioType.equalsIgnoreCase("vlc"))
		{
			advancedMusicPlayer.playVlc(fileName);
		} else if (audioType.equalsIgnoreCase("mp4"))
		{
			advancedMusicPlayer.playMp4(fileName);
		}
	}
}
